// Utilities
import { defineStore } from 'pinia'

export const userStore = defineStore('user', {
    state: () => ({
        userInfo: {
            id: "",
            email:"",
            first_name:"",
            last_name:"",
            mobile:"",
            token:"",
            address: ""
        }
    }),
    getters: {
    },
    actions: {
        setToken(token) {
            this.userInfo.token = token
        },
        setUserInfo(userInfo) {
            this.userInfo.email = userInfo.email
            this.userInfo.first_name = userInfo.first_name
            this.userInfo.last_name = userInfo.last_name
            this.userInfo.mobile = userInfo.mobile
            this.userInfo.id = userInfo.id
            this.userInfo.address = userInfo.address
        },
        outLogin() {
            this.userInfo = {}
        }
    },
    persist: true, // 设置持久化
    // 单独设置存储位置
    // persist: {
    //   storage: window.localStorage,
    // },
});
